#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
typedef struct LNode {
    int data;
    struct LNode *next;
} LNode, *LinkList;
void CreateList(LinkList &L, int n) {
    LinkList p, q;
    L = new LNode;
    L->next = NULL;
    q = L;
    for(int i = 0; i < n; i++) {
        p = new LNode;
        scanf("%d", &p->data);
        p->next = NULL;
        q->next = p;
        q = p;
    }
}
void Delete(LinkList &L) {
    LinkList p, q = L, r = NULL, t;
    for(p = L->next; p != NULL; p = p->next) {
        r = p;
        q = p->next;
        while(q) {
            if(p->data == q->data) {
                t = q;
                r->next = q->next;
                q = q->next;
                free(t);
            } else {
                r = q;
                q = q->next;
            }
        }
    }
}
void Load(LinkList L) {
    LinkList p = L->next;
    while(p) {
        printf("%d ", p->data);
        p = p->next;
    }
    printf("\n");
}
int main() {
    LinkList L;
    int n;
    scanf("%d", &n);
    CreateList(L, n);
    Load(L);
    Delete(L);
    Load(L);
    return 0;
}
